package com.sumainfor.pc.gmio.controller.tenant;

import com.sumainfor.common.util.FieldCheckUtil;
import com.sumainfor.common.util.JsonResult;
import com.sumainfor.pc.gmio.service.impl.tenant.TeWithdrawalService;
import org.apache.commons.collections.MapUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * 功能描述:
 * 租客退租账单
 * @Auther: zhlu
 * @Date: 2019/5/18 10:34
 * @Description:
 */
@RestController
@RequestMapping("/tenant/key/with")
public class TeWithdrawalController {

    @Autowired
    TeWithdrawalService TeWithdrawalService;

    /**
     * 功能描述: 
     * 根据退租账单编号和租客编号获取退租账单
     * @Author zhlu
     * @Description //TODO
     * @Date 2019/5/18 10:39
     */
    @ResponseBody
    @RequestMapping(value = "/getTanantWithdrawalMap",method = RequestMethod.GET)
    public JsonResult getTanantWithdrawalMap(@RequestParam Map<String,Object>params){
        JsonResult result=new JsonResult();
        if(!FieldCheckUtil.isMapFieldNotNull(params,new String[]{"PaId"})){
            result.putFailed("PaId不能为空！");
            return  result;
        }
        if(!FieldCheckUtil.isMapFieldNotNull(params,new String[]{"TenId"})){
            result.putFailed("TenId不能为空！");
            return  result;
        }
        Map<String,Object> getTanantWithdrawalMap=TeWithdrawalService.getTanantWithdrawalMap(params);
        if(MapUtils.isNotEmpty(getTanantWithdrawalMap)){
            result.put(getTanantWithdrawalMap);
        }else{
            result.putFailed("暂无当前账单！");
        }
        return result;
    }

    /**
     * 功能描述: 
     * 根据退租账单获取退租结算单
     * @Author zhlu
     * @Description //TODO
     * @Date 2019/5/20 10:21
     */
    @ResponseBody
    @RequestMapping(value = "/getTanantWithdrBill",method = RequestMethod.GET)
    public JsonResult getTanantWithdrBill(@RequestParam Map<String,Object>params){
        JsonResult result=new JsonResult();
        if(!FieldCheckUtil.isMapFieldNotNull(params,new String[]{"WitId"})){
            result.putFailed("WitId不能为空！");
            return  result;
        }
        if(!FieldCheckUtil.isMapFieldNotNull(params,new String[]{"TenId"})){
            result.putFailed("TenId不能为空！");
            return  result;
        }
        return result.put(TeWithdrawalService.getTanantWithdrBill(params));
    }

    /**
     * 功能描述: 
     * 根据退租账单编号获取退租物品清单
     * @Author zhlu
     * @Description //TODO
     * @Date 2019/5/20 11:51
     */
    @ResponseBody
    @RequestMapping(value = "/getWithArticleList",method = RequestMethod.GET)
    public JsonResult getWithArticleList(@RequestParam Map<String,Object>params){
        JsonResult result=new JsonResult();
        if(!FieldCheckUtil.isMapFieldNotNull(params,new String[]{"WitId"})){
            result.putFailed("WitId不能为空！");
            return  result;
        }
        if(!FieldCheckUtil.isMapFieldNotNull(params,new String[]{"TenId"})){
            result.putFailed("TenId不能为空！");
            return  result;
        }
        return result.put(TeWithdrawalService.getWithArticleList(params));
    }

}
